package com.yanzhu.service.mapper;

import com.yanzhu.service.model.Rank;
import com.yanzhu.service.model.mix.RankInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: 方炎柱
 * @Description:
 * @Date: Created in 15:11 2018/2/5
 * @Modified:
 */
@Mapper
public interface RankMapper {
    @Insert("insert into rank(uid, vid, like_speed) values(#{uid}, #{vid}, #{like_speed})")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = long.class)
    int insert(Rank rank);

    @Select("select r.uid, r.vid, r.like_speed, u.nickname, u.avatar" +
            " from rank r" +
            " left join user u on u.id = r.uid" +
            " where r.vid = #{vid}" +
            " order by r.like_speed asc" +
            " limit 0, #{size}")
    List<RankInfo> queryVideoLikeRank(@Param("vid") long vid, @Param("size") int size);
}
